/*
 * Copyright 2003-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package gs

import junit.framework.AssertionFailedError

class GroovierSeleniumTest extends GroovierSeleniumTestCase {
    def GroovierSeleniumTest(String name) {
        super(name);
    }

    void setUp() {
        setUp "http://blog.fredjean.net/"
    }

    void testOpenSite() {
        open "/"
        assert title == "Out of my mind..."
        click "link=Development Process"
        waitForPageToLoad 30000
        assert title == "Out of my mind... : category development-process"
    }

    void testAdminLogin() {
        open "/admin"
        if (location == "http://blog.fredjean.net/accounts/login") {
            assert title == "Typo Administration: accounts"
            type "user_login", "fredjean"
            type "user_password", "notmypassword"
            click "login"
            // Expecting this to timeout. Testing time out here.
            try {
                waitForTextPresent 30000, "Login successful"
            } catch (AssertionFailedError afe) {
                assertNotTextPresent("Login successful")
                assertTextPresent("Login unsuccessful")
            }
        }
    }
}